package com.boot.web.http;

/**
 * @author 霜寒 <1621856595@qq.com>
 * @description 业务状态码
 * 1XX代表语言层和框架层
 * 2XX代表数据库层
 * 3XX代表业务层
 * 4XX代表对外接口层
 * @date 2019/8/16 15:21
 **/
public enum Status {

    /***************************** 1XX *********************************/

    NOT_CONVERT(100, "无法转化实例"),

    NONE_BEAN(101, "bean为空对象"),

    NONE_FIELD(102, "某些值必须存在"),

    /***************************** 2XX *********************************/

    DATABASE_ERROR(200, "数据库异常"),

    RECORD_EXIST(201, "已经存在该记录"),

    NO_RECORD(202, "无法找到记录"),

    INSERT_FAILURE(203, "无法插入记录"),

    UPDATE_FAILURE(204, "无法更新记录"),

    DELETE_FAILURE(205, "无法删除记录"),

    READONLY_FAILURE(206, "只读记录，无法修改或删除"),

    /***************************** 3XX *********************************/

    NO_USER(300, "找不到用户"),

    NO_ROLE(301, "找不到角色"),

    NO_ACCESS(302, "找不到权限"),

    NO_RESOURCE(303, "找不到资源"),

    PATTERN_INVALID(304, "匹配正则表达式失败"),

    SPECIAL_CHAR(305, "含有特殊字符"),

    NO_PHONE(306, "无法找到电话"),

    NO_MAIL(307, "无法找到邮箱"),

    MAIL_INIT_FAILURE(308, "无法初始化邮件"),

    NO_CAPTCHA(309, "找不到该验证码"),

    CAPTCHA_MATCH_FAILURE(310, "验证码不匹配"),

    STATE_ERROR(311, "内部状态异常"),

    /***************************** 4XX *********************************/

    NO_REQUEST(400, "无法解析请求"),

    LOGIN_FAILURE(401, "登录失败"),

    PASSWORD_ERROR(402, "密码错误"),

    JSON_FAILURE(403, "JSON转化失败"),

    TOKEN_WARN(404, "token即将过期"),
    TOKEN_EXPIRED(405, "token过期"),

    TOKEN_INVALID(406, "token无效"),

    ID_INVALID(407, "id不能为空或小于1"),

    ACCOUNT_LOCKED(408, "账号锁定"),

    PARAM_ERROR(409, "参数异常"),

    /**************************** Other ********************************/

    UNKNOWN_ERROR(500, "未知错误"),

    SUCCESS(0, "操作成功");

    Status(Integer code, String description) {
        this.status = code;
        this.description = description;
    }

    /**
     * @description 业务状态码
     * @date 2019/8/16 15:23
     **/
    private final Integer status;
    /**
     * @description 业务状态描述
     * @date 2019/8/16 15:23
     **/
    private final String description;

    public Integer getStatus() {
        return status;
    }

    public String getDescription() {
        return description;
    }

    @Override
    public String toString() {
        return getStatus() + " : " + description;
    }
}
